<template>
    <!-- 监测内容 -->
    <base-breadcrumb :title="$route.meta.title">
        <!-- 搜索 -->
        <searchData :searchData="searchArr" @search="search"></searchData>
        <!-- 表格 -->
        <a-card :bordered="false">
            <!-- <title-name :title="$route.meta.title"></title-name> -->
            <a-button class="mb12" icon="plus" type="primary" @click="handleManage(2)" v-btnPermission="'tm_035_add_01'">新增</a-button>
            <!-- 表格 -->
            <list-table
                ref="table"
                tableLayout="fixed"
                size="default"
                rowKey="id"
                :columns="columns"
                :request="loadData"
                :page-keys="['pageNum', 'pageSize','totalSize']"
                :alert="true"
                show-size-changer
                show-quick-jumper
                showPagination="auto"
            >
                <template slot="action" slot-scope="text, record">
                    <MoreButton>
                    <a @click="handleManage(0, record)" v-btnPermission="'tm_035_loo_04'">查看</a>
                    <span v-btnPermission="'tm_035_edi_02'" >
                        <a-divider type="vertical" />
                        <a @click="handleManage(1, record)">编辑</a>
                        </span>  
                    <!-- 删除 -->
                    <span v-btnPermission="'tm_035_del_03'">
                        <a-divider type="vertical"></a-divider>
                        <a @click="handleRemoveParams({ id: record.id })">删除</a>
                    </span>
                    </MoreButton>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { getPageTechnicalMeasurementMonitoringList, deleteTechnicalMeasurementMonitoringById} from '@/api/technical/measurement' // api
import BasePage from '@/views/basePage' // 基础配置
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import OrgTreeSelect from '@/components/OrgTreeSelect'
import { monitoringData,conclusionMonitoringData} from './model'
import { measurementMixin } from './minixs'
const columns = [
    // {title: '序号',width: 80,dataIndex: 'index',
    //     customRender() {
    //         return arguments[2] + 1
    //     }
    // },
    {title: '所属分公司',dataIndex: 'branchComName',ellipsis: true,width: 150,},
    {title: '所属项目',dataIndex: 'projectName',ellipsis: true,width: 150,},
    {title: '监测内容',dataIndex: 'monitoringContentName',ellipsis: true,width: 180,},
    {title: '监测时间',dataIndex: 'monitoringTime',ellipsis: true,width: 150,},
    {title: '工程部位',dataIndex: 'projectPosition',ellipsis: true,width: 150,},
    {title: '参与人员',dataIndex: 'participantName',ellipsis: true,width: 180,},
    {title: '监测频率要求',dataIndex: 'monitoringFrequencyName',ellipsis: true,width: 180,},
    {title: '监测结论',dataIndex: 'conclusionMonitoringName',ellipsis: true,width: 180,},
    {title: '填报人',dataIndex: 'modifiedName',width: 200,ellipsis: true},
    {title: '填报时间',dataIndex: 'modifiedTime',ellipsis: true, width: 200,},
    {title: '操作',dataIndex: 'action',width: '280px',align: 'center',scopedSlots: { customRender: 'action' },  fixed: 'right',}
]
export default {
mixins:[measurementMixin], //混入文件
    name: 'a' + Date.now(),
    extends: new BasePage(),
    components: {
        STable
    },
    data() {
        this.columns = columns
        return {
            searchArr:[
                // 搜索框
                // {name: '所属分公司', valueKey: 'branchComId', type: SelectSubCompany},
                {
                  name: '所属单位',
                  valueKey: 'searchQuery',
                  type: OrgTreeSelect,
                },
                // {name: '所属项目',keyValue: 'branchComId',valueKey: 'projectId',type: SelectProject},
                {name: '监测内容',type: 'select', value: 'monitoringContent', data:[],  attrs: {
                    replaceFields: {children:'children', title:'monitoringContentName', key:"id", value: 'id' }
                  }},

                {name: '监测时间',type: 'dateRange',value: 'monitoringTime',
                    attr: {
                        rangeFormat: ['startTime', 'endTime']
                    }
                },
                {name: '参与人员',type: 'input',value: 'participantName'},
                {name: '监测频率要求',type: 'select',value: 'monitoringFrequency',
                data:monitoringData
                },
                {name: '监测结论',type: 'select',value: 'conclusionMonitoring',
                data: conclusionMonitoringData
            },
              {name: '工程部位',type: 'input',value: 'projectPosition'},
            ],
            queryParam: {}, // 查询参数
            loadData: async (parameter) => {
                const requestParameters = Object.assign({}, parameter, { param: this.queryParam })
                return getPageTechnicalMeasurementMonitoringList(requestParameters).then((res) => {
                 return res;
                })
            },
            removeApi: { remove: deleteTechnicalMeasurementMonitoringById },// api
            SummaryData:{
                confirmAmountHas:0,
                correspondingCostHaveVat:0,
                number:0,
                profitRate:0,
                submitMoneyHaveVat:0
            }    //汇总
        }
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            let query = {
                editModel: type
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: 'updateMeasurement',
                query
            })
        }
    },
   async mounted(){
    await  this.getPageTechnicalMonitoringContentListFn();
        this.$set(this.searchArr,1,{name: '监测内容',
          type: 'tree-select',
          value: 'monitoringContent',
          data:this.monitoringContentData,
          attrs: {
              replaceFields: {children:'children', title:'monitoringContentName', key:"id", value: 'id' }
            }},
); 
    }
}
</script>
